/*
 * @Author: qin
 * @Date:   2018-08-28
 * +----------------------------------------------------------------------
 * | admin [ 后台管理系统公共配置信息 ]
 * | 开发环境，意见模块
 * +----------------------------------------------------------------------
 */
layui.define(['configure', 'configureCom', 'sessionFun'], function (exports) {
    var configureCom = layui.configureCom;
    var configure = layui.configure;
    var sessionFun = layui.sessionFun;
    var listData = sessionFun.get(configure.SESSION_PROJECT_WAIT_LIST_DATA);
    var drawingData = sessionFun.get(configure.SESSION_DRAWING_DATA);
    var suggest = {
        //意见--添加意见
        add: function (data) {
            return new Promise(function (resolve) {
                //获取当前审查对象
                data.decId = listData.decId;//申报id
                data.specialtyId = drawingData.specialtyId;//专业id
                data.drawingId = drawingData.id ;//图纸id
                data.circleFontSize = configure.circleFontSize;//字体大小
                // 添加意见
                configureCom.postDataAjax(configure.EXPERT_ADD_UPDATE_SUGGEST_HTTP, data).then(function (res) {
                    resolve(res);
                }, function (err) {
                    alert(JSON.stringify(err));
                });
            });
        },
        //意见库--修改意见
        change: function (data) {
            return new Promise(function (resolve) {
                configureCom.postDataAjax(configure.EXPERT_CHANGE_SUGGEST_BASE_HTTP, data).then(function (res) {
                    resolve({code: res.code, msg: res.msg, result: res.result});
                });
            });
        },
        //查询一条意见
        infoList: function (data) {
            return new Promise(function (resolve) {
                var data ={};
                data.decId = listData.decId;//申报id
                data.specialtyId = drawingData.specialtyId;//专业id
                configureCom.postDataAjax(configure.EXPERT_SPECITY_INFO_HTTP, data).then(function (res) {
                    resolve({code: res.code, msg: res.msg, result: res.result});
                });
            });
        },
        //获取意见列表
        getList: function () {
            return new Promise(function (resolve) {
                var data ={};
                data.decId = listData.decId;//申报id
                data.specialtyId = drawingData.specialtyId;//专业id
                configureCom.postDataAjax(configure.EXPERT_SPECITY_SUGGEST_HTTP,data).then(function (res) {
                    resolve({code: res.code, msg: res.msg, result: res.page});
                });
            });
        },
        //获取单位工程下机构分类
        getOrg: function (data) {
            return new Promise(function (resolve) {
                //获取当前审查对象
                var expertData = sessionFun.get(configure.SESSION_EXPERT_DATA);
                configureCom.getAjax(configure.EXPERT_ORG_TYPE_HTTP, {singleProjectId: expertData.sgProjId}).then(function (res) {
                    resolve({code: res.code, msg: res.msg, result: res.result});
                });
            });
        },
        //删除专业意见
        deleteSuggest: function (data) {
            return new Promise(function (resolve) {
                configureCom.postDataAjax(configure.EXPERT_DELETE_SUGGEST_HTTP, {adviseId: data.adviseId}).then(function (res) {
                    resolve({code: res.code, msg: res.msg, result: res.result});
                });
            });
        },
        //删除意见库意见
        deleteSuggestBank: function (data) {
            return new Promise(function (resolve) {
                configureCom.postDataAjax(configure.EXPERT_DELETE_SUGGEST_BASE_HTTP, {bankId: data.bankId}).then(function (res) {
                    resolve({code: res.code, msg: res.msg, result: res.result});
                });
            });
        },
        //确认修改之前轮数意见
        confirmChange: function () {
            return new Promise(function (resolve) {
                //获取修改前意见对象
                var suggestData = sessionFun.get(configure.SESSION_SUGGEST_DATA);
                configureCom.putDataAjax(configure.EXPERT_CONFIRM_CHANGE_HTTP, {adviseId: suggestData.adviseId}).then(function (res) {
                    resolve({code: res.code, msg: res.msg, result: res.result});
                });
            });
        }
    };
    exports('suggest', suggest);
});